package com.tul.exercise.base.clazz.base.eg1;

/**
 * 《java编程思想》 14.2 练习题：向下类型转换
 */
public class RhomboidTest {

    public static void main(String[] args) {
        Rhomboid r = new Rhomboid();

        Shape shape = r;

        // 不能直接向下类型转换
        // Rhomboid rhomboid = shape;

        // 向下类型转换之前，先判断类型是否匹配
        if(shape instanceof Rhomboid) {
            Rhomboid rhomboid = (Rhomboid)shape;

            rhomboid.draw();
        }
    }
}
